package com.example.mallcoupon.service.Impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mallcoupon.feign.MemberFeignService;
import com.example.mallcoupon.mapper.CouponMapper;
import com.example.mallcoupon.pojo.TCoupon;
import com.example.mallcoupon.service.CouponService;
import io.seata.spring.annotation.GlobalTransactional;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CouponServiceImpl extends ServiceImpl<CouponMapper, TCoupon> implements CouponService {
	@Autowired
	private MemberFeignService memberFeignService;


	@Override
	@SentinelResource("query")
	public void query1() {
		System.out.println("测试链路");
	}

	@Override
	@GlobalTransactional
	public void saveAll() {
		// 本项目
		TCoupon tCoupon = new TCoupon();
		tCoupon.setName("coupon");
		tCoupon.setAge(18);
		baseMapper.insert(tCoupon);

		// feign接口
		memberFeignService.saveFeign();
		throw new  RuntimeException("异常");

	}


}
